@import 'settings';

@mixin vf-p-modal {
  $icon-size: map-get($icon-sizes, default);

  .p-modal {
    align-items: center;
    background: $colors--theme--background-overlay;
    bottom: 0;
    display: flex;
    height: 100dvh;
    justify-content: center;
    left: 0;
    margin: 0;
    padding: $spv--large;
    position: fixed;
    right: 0;
    top: 0;
    width: 100%;
    z-index: 150; // render on top of any other content or layout elements
  }

  .p-modal__dialog {
    @extend %vf-card-padding;
    @extend %vf-has-box-shadow;

    background-color: $colors--theme--background-default;
    color: $colors--theme--text-default;
    left: $sph--x-large;
    margin-bottom: 0;
    max-height: calc(100% - 2 * $spv--large);
    max-width: $grid-max-width;
    overflow: auto;
    padding-top: 0;
    position: absolute;
    right: $sph--x-large;
    width: auto;

    @media (min-width: $threshold-6-12-col) {
      bottom: initial;
      left: initial;
      position: relative;
      right: initial;
      top: initial;
    }
  }

  .p-modal__header {
    @extend %vf-pseudo-border--bottom;

    background: $colors--theme--background-default;
    display: flex;
    justify-content: space-between;
    margin-bottom: $spv--small;
    // add padding to accommodate the width of p-modal__close
    padding-right: $icon-size + $sph--small * 2;
    padding-top: $spv--large;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .p-modal__title {
    @extend %vf-heading-4;

    align-self: flex-end;
  }

  .p-modal__close {
    @include vf-icon-close-themed;
    background: {
      position: center;
      repeat: no-repeat;
      size: $icon-size;
    }

    border: 0;
    box-sizing: content-box;
    height: $icon-size;
    margin: 0;
    margin-top: $spv--large;
    padding: $sp-unit;
    position: absolute;
    right: 0;
    text-indent: -999em;
    top: 0;
    width: $icon-size;
  }

  .p-modal__footer {
    @extend %vf-pseudo-border--top;

    padding-top: 1rem;
    text-align: right;
  }
}
